home *** CD-ROM | disk | FTP | other *** search
- Path: dakal.demon.co.uk!richardlh
- From: Richard Linsley Hood <richardlh@dakal.demon.co.uk>
- Newsgroups: comp.lang.c++,comp.lang.pascal.delphi.misc
- Subject: Re: C++ with Zapp vs. Delphi
- Date: Sat, 20 Jan 1996 15:32:07 +0000
- Organization: Dakal Systems Ltd
- Distribution: world
- Message-ID: <GK+N9LA3rQAxEwdx@dakal.demon.co.uk>
- References: <4coar6$d4n@sun4.bham.ac.uk> <4coip7$69s@news1.usa.pipeline.com>
- <DBk8wg2yqjbB083yn@iaccess.za> <4d7pmb$48c8@tigger.cc.uic.edu>
- <4dk38h$gdr@merlin.delphi.com> <4dksp1$3d6c@tigger.cc.uic.edu>
- <30fe666e.3349285@130.15.126.54> <4dmjt8$6sv@crc-news.doc.ca>
- <30ff9519.1799465@130.15.126.54> <4doe07$4u8@crc-news.doc.ca>
- <30ffe557.16481026@130.15.126.54>
- NNTP-Posting-Host: dakal.demon.co.uk
- X-NNTP-Posting-Host: dakal.demon.co.uk
- MIME-Version: 1.0
- X-Newsreader: Turnpike Version 1.10 <EdeHes6g1FnzvsX+Q8nYPyW0xw>
-
- In article <30ffe557.16481026@130.15.126.54>, Duncan Murdoch
- <dmurdoch@mast.queensu.ca> writes
- >On 19 Jan 1996 15:39:51 GMT, Slobodan Celenkovic <slobodan@cs.unh.edu>
- >wrote:
- >
- >>Sorting algorithm is still in the list class (binary search, quick sort,
- >>..). However the item comparison shouldn't go into the list class, but
- >>item classes. Why? Because items "know" how to compare themselves to
- >>other items.
- >
- >I hate to repeat myself, but what if I want to put something into two
- >different lists? Then the item has to know which list you're calling
- >its Compare from. Makes a lot more sense to me to have the Compare as
- >a method of the list. Then my AlphabeticalList can compare
- >alphabetically, and my NumericalList can compare numerically.
-
- The method and order by which comparisons are done is determined by the
- list. This is quite reasonably part of its function. It 'knows' about
- which two items should be compared to determine which is larger,
- smaller, etc., thus it is part of its function.
-
- The comparison of two objects should be done by themselves, 'are you
- larger, smaller than this object' thus hiding from the list how this is
- done. Only an object 'knows' how it compares to another object (of the
- same type). This is quite reasonably a function of the object.
-
- Where is the problem?
-
- You now have a generic list, capable of storing and sorting any object.
- You have generic objects that are capable of being stored in lists,
- queues, btrees, etc.
-
- Why do you wish to make life more complicated that necessary?
-
- --
- Richard Linsley Hood | Poole, Dorset UK | email: richardlh@dakal.demon.co.uk
- "Programming is mirroring the world, inside a computer" Larry O'Brien 1991
-